/**
 * file
 */
package com.tdkj.action.front.member.seller.shop;

import java.util.List;
import javax.annotation.Resource;

import com.opensymphony.xwork2.ActionContext;
import com.tdkj.action.BaseAction;
import com.tdkj.model.shop.BeanShelfCustom;
import com.tdkj.model.shop.BeanShelfCustomBuy;
import com.tdkj.model.user.BeanUser;
import com.tdkj.service.ServiceException;
import com.tdkj.service.shop.IBeanShelfCustomBuyService;
import com.tdkj.service.shop.IBeanShelfCustomService;
import com.tdkj.util.PublicConfing;

public class ShelfAction extends BaseAction {
	
	private Long id;
	private Long customId;
	private Long userId;
	
	private BeanShelfCustomBuy buy;
	
	private List<BeanShelfCustomBuy> buys;
	
	private List<BeanShelfCustom> customs;
	
	private IBeanShelfCustomBuyService shelfCustomBuyService;
	
	private IBeanShelfCustomService shelfCustomService;
	
	@Override
	public String execute() {
		BeanUser user  = (BeanUser)ActionContext.getContext().getSession().get(PublicConfing.MEMBER_MEMBWE_OBJ_STRING_CONFIG);
		userId = user.getId();
		
		buys = shelfCustomBuyService.getBuyLogs(userId);
		
		customs = shelfCustomService.findAll(BeanShelfCustom.class);
		return "success";
	}
	
	public String add() throws ServiceException {
		BeanUser user  = (BeanUser)ActionContext.getContext().getSession().get(PublicConfing.MEMBER_MEMBWE_OBJ_STRING_CONFIG);
		userId = user.getId();
		
		shelfCustomBuyService.add(userId, customId);
		return execute();
	}
	
	public String customs() {
		customs = shelfCustomService.findAll(BeanShelfCustom.class);
		return "customs";
	}

	/**
	 * @return the id
	 */
	public Long getId() {
		return id;
	}

	/**
	 * @param id the id to set
	 */
	public void setId(Long id) {
		this.id = id;
	}

	/**
	 * @return the customId
	 */
	public Long getCustomId() {
		return customId;
	}

	/**
	 * @param customId the customId to set
	 */
	public void setCustomId(Long customId) {
		this.customId = customId;
	}

	/**
	 * @return the userId
	 */
	public Long getUserId() {
		return userId;
	}

	/**
	 * @param userId the userId to set
	 */
	public void setUserId(Long userId) {
		this.userId = userId;
	}

	/**
	 * @return the buy
	 */
	public BeanShelfCustomBuy getBuy() {
		return buy;
	}

	/**
	 * @param buy the buy to set
	 */
	public void setBuy(BeanShelfCustomBuy buy) {
		this.buy = buy;
	}

	/**
	 * @return the buys
	 */
	public List<BeanShelfCustomBuy> getBuys() {
		return buys;
	}

	/**
	 * @param buys the buys to set
	 */
	public void setBuys(List<BeanShelfCustomBuy> buys) {
		this.buys = buys;
	}

	/**
	 * @return the customs
	 */
	public List<BeanShelfCustom> getCustoms() {
		return customs;
	}

	/**
	 * @param customs the customs to set
	 */
	public void setCustoms(List<BeanShelfCustom> customs) {
		this.customs = customs;
	}

	@Resource
	public void setShelfCustomBuyService(
			IBeanShelfCustomBuyService shelfCustomBuyService) {
		this.shelfCustomBuyService = shelfCustomBuyService;
	}

	@Resource
	public void setShelfCustomService(IBeanShelfCustomService shelfCustomService) {
		this.shelfCustomService = shelfCustomService;
	}
	
}
